home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / airfoil.src < prev    next >
Text File  |  1991-05-29  |  7KB  |  196 lines

  1. %%HP: T(3)A(R)F(.);
  2. @ AIRFOIL, by Matt Nelson
  3. DIR
  4. AIRFOIL
  5. \<<
  6.   "Airfoil?"               @ prompt for airfoil name
  7.   {1}
  8.   INPUT
  9.   OBJ\->              @ get the data array on the stack
  10.   DUP IF TYPE 4 \=/ THEN   @ check to see if this is a complex
  11.     "Not airfoil data"          @ array; assumes any complex array
  12.     DOERR             @ in this directory IS airfoil data
  13.     DROP
  14.     KILL              @ if not, kill the program
  15.   END
  16.   43 MENU             @ select UNITS LENG menu
  17.   "Chord?"            @ prompt for desired chord
  18.   {1}
  19.   INPUT
  20.   OBJ\->              @ put chord on stack
  21.   0 MENU              @ return to previous menu
  22.   CLLCD
  23.   "   working..." 3 DISP   @ display info message
  24.   DUP                 @ get type of argument
  25.   IF TYPE 13 == THEN       @ it is a unit object
  26.     '1_cm' CONVERT         @ assume unit is length, so convert to cm
  27.     OBJ\-> DROP            @ get rid of its unit
  28.   END
  29.   PPAR                @ get current PPAR so we can save it
  30.   \-> chord ppar      @ save desired chord, in cm, and PPAR
  31.   \<<
  32.     # 64d             @ eventual width of PICT we will want
  33.     chord ycmps /          @ required height of PICT, in screens
  34.     CEIL              @ required height of PICT, in integer screens
  35.     \-> nscreen            @ we will need number of screens later
  36.     \<<  {
  37.       (-1.82,0) (1.82,2.11)     @ put a PPAR on stack, so that we have
  38.       X 0 (0,0) FUNCTION Y }    @ something to work with...
  39.       1                    @ PUT index for pmin
  40.       xcmps 2 / NEG        @ get xmin from the real width of output
  41.       0 R\->C PUT          @ put (xmin,0) into our PPAR
  42.       2                    @ PUT index for below...
  43.       xcmps 2 /            @ get xmax from the real width of output
  44.       nscreen ycmps *      @ new ymax = #screens * (cm/screen)
  45.       R\->C PUT            @ make it complex, and shove it into PPAR
  46.       'PPAR' STO      @ store it for use
  47.       nscreen 64 * R\->B PDIM   @ make PICT the appropriate size
  48. @
  49. @ at this point, we still have the array of coordinates on the stack,
  50. @ so re-scale them into cm
  51. @
  52.       DUP SIZE OBJ\-> DROP @ get size of array
  53.       -100 100 -100 100         @ initialize xmax=ymax=-100, xmin=ymin=100
  54.       \-> size xmax xmin ymax ymin
  55.       \<<
  56.         1 1 size
  57.         START              @ scan the array looking for max & min x
  58.           GETI C\->R       @ get the x and y coord
  59.           \-> x y
  60.           \<<
  61.             x xmin MIN          @ put minimum of x and xmin in xmin
  62.             'xmin' STO
  63.             x xmax MAX          @ put maximum of x and xmax in xmax
  64.             'xmax' STO
  65.             y ymin MIN          @ put minimum of y and ymin in ymin
  66.             'ymin' STO
  67.             y ymax MAX          @ put maximum of y and ymax in ymax
  68.             'ymax' STO
  69.           \>>
  70.         NEXT
  71.         DROP               @ get rid of the GETI index
  72.         1 1 size 1 -
  73.         START DUP NEXT          @ make two arrays of 1's, size of data
  74.         size 1 \->LIST \->ARRY DUP
  75.         ROT C\->R               @ get y-coordinates
  76.         4 ROLL ymax ymin + 2 / *     @ make array of average y value
  77.         -                  @ shift y values by subtracting average
  78.         3 ROLLD SWAP xmin * -   @ subtract xmin from all x values
  79.         SWAP R\->C         @ re-pack complex array, now has [0,1] x-range
  80.         chord *            @ multiply by chord for proper scale
  81. @
  82. @ we now have a properly scaled array of coordinates on the stack, so
  83. @ connect the dots between adjacent points
  84. @
  85.         ERASE              @ clear PICT
  86.         1 size 1 -         @ need one less than size of the array
  87.         FOR i
  88.           DUP i GETI
  89.           4 ROLLD GET ROT  @ put the first pair of points on the stack
  90.           C\->R SWAP R\->C @ swap x and y so foil comes out long-wise
  91.           SWAP
  92.           C\->R SWAP R\->C @ do same with 2nd point
  93.           LINE             @ draw a line between the two points
  94.         NEXT
  95.         DROP               @ don't need the array of points anymore
  96.       \>>
  97. @
  98. @ now PICT has the airfoil drawn on it, so display it screen
  99. @ by screen, dumping it to the printer
  100. @
  101.       CR              @ put print head over to right
  102.       1 nscreen            @ there will be nscreen dumps
  103.       FOR i
  104.         # 0d               @ upper left hand x-pixel coordinate to display
  105.         i 1 - 64 * R\->B   @ upper right hand y-pixel coordinate "
  106.         2 \->LIST          @ put pixel coordinates in a list
  107.         PVIEW              @ and display PICT
  108.         PRLCD              @ send display to printer
  109.       NEXT
  110.     \>>
  111. @
  112. @ we is done, so clean up
  113. @
  114.     ppar DUP
  115.     IF TYPE 6 == THEN      @ there was no PPAR, and we just saved a name
  116.       DROP            @ at top of program; just drop it
  117.       'PPAR' PURGE         @ and get rid of the one we created
  118.     ELSE
  119.       'PPAR' STO      @ there was a PPAR, so restore it
  120.     END
  121.     PICT PURGE             @ get back the memory used by PICT
  122.   \>>
  123. \>>
  124.  
  125.  
  126. ycmps                 @ height of one screen of PRINTED OUTPUT, cm
  127.   2.096
  128.  
  129. xcmps                 @ width of one screen of PRINTED OUTPUT, cm
  130.   3.60
  131.  
  132. SD7003                @ sample airfoil, the Selig-Donovan 7003
  133.   [ (1.00000,0.0)
  134.     (0.99681,0.00031)
  135.     (0.98745,0.00132)
  136.     (0.97235,0.00310)
  137.     (0.95193,0.00547)
  138.     (0.92639,0.00824)
  139.     (0.89600,0.01139)
  140.     (0.86112,0.01494)
  141.     (0.82224,0.01884)
  142.     (0.77985,0.02304)
  143.     (0.73449,0.02744)
  144.     (0.68673,0.03197)
  145.     (0.63717,0.03649)
  146.     (0.58641,0.04086)
  147.     (0.53499,0.04494)
  148.     (0.48350,0.04859)
  149.     (0.43249,0.05171)
  150.     (0.38250,0.05415)
  151.     (0.33405,0.05581)
  152.     (0.28760,0.05658)
  153.     (0.24358,0.05639)
  154.     (0.20240,0.05518)
  155.     (0.16442,0.05292)
  156.     (0.12993,0.04961)
  157.     (0.09921,0.04526)
  158.     (0.07244,0.03993)
  159.     (0.04978,0.03372)
  160.     (0.03130,0.02677)
  161.     (0.01702,0.01932)
  162.     (0.00697,0.01172)
  163.     (0.00127,0.00438)
  164.     (0.00025,-0.00186)
  165.     (0.00457,-0.00741)
  166.     (0.01408,-0.01285)
  167.     (0.02839,-0.01759)
  168.     (0.04763,-0.02141)
  169.     (0.07182,-0.02438)
  170.     (0.10073,-0.02660)
  171.     (0.13407,-0.02809)
  172.     (0.17150,-0.02888)
  173.     (0.21268,-0.02900)
  174.     (0.25719,-0.02852)
  175.     (0.30456,-0.02752)
  176.     (0.35426,-0.02608)
  177.     (0.40572,-0.02428)
  178.     (0.45837,-0.02217)
  179.     (0.51161,-0.01980)
  180.     (0.56484,-0.01723)
  181.     (0.61748,-0.01450)
  182.     (0.66898,-0.01167)
  183.     (0.71883,-0.00887)
  184.     (0.76644,-0.00628)
  185.     (0.81118,-0.00403)
  186.     (0.85241,-0.00220)
  187.     (0.88957,-0.00082)
  188.     (0.92210,0.00008)
  189.     (0.94952,0.00052)
  190.     (0.97134,0.00057)
  191.     (0.98718,0.00037)
  192.     (0.99679,0.00011)
  193.     (1.00001,-0.00000) ]
  194.  
  195. END
  196.